const Service = require('egg').Service

class HsService extends Service {
  /**
   * 通过乡镇获取返乡报备总人数
   * @param {*} name
   */
  async reportTotalByTown(town) {
    const { knex } = this.app
    const { TABLE_PERSON_BACK_HOME } = this.config.constant

    return knex(TABLE_PERSON_BACK_HOME)
      .where('to_county_code', town)
      .count()
      .then(res => {
        return res[0]['count(*)']
      })
  }
}

module.exports = HsService
